<?php

	/**
	 * @see Bike_Form_Renderer_ExtJs_Field_Validate_Abstract
	 */
	require_once 'Bike/Form/Renderer/ExtJs/Field/Validate/Abstract.php';
	
	
	class Bike_Form_Renderer_ExtJs_Field_Validate_Identical extends Bike_Form_Renderer_ExtJs_Field_Validate_Abstract
	{		public function getSettings()
		{			$js = $this->getJs();
			$Error = $this->translate('Values are not identical');
			$settings = array(
				'validator' => $js->function($js->value)
									->_body(array(
										$js->_var($js->result)->_val($js->false),
										$js->this->up('form')->items->each($js->function($js->item)
											->_body(array(
												$js->_var($js->name)->_val($js->item->_method('getName')),
												$js->if($js->name->_eq($this->getValidator()->getToken()))
													->_body(array(
														$js->if($js->value->_neq($js->item->getRawValue()))
															->_body(array(
																$js->item->markInvalid($Error),
																$js->result->_val($Error),
																$js->return($js->true),
															)),
														$js->result->_val($js->true),
														$js->item->clearInvalid(),
														$js->return($js->true),
													)),
											))
										),
										$js->if($js->_not($js->result))
											->_body(array(
												$js->return($this->translate('There is no source to compare'))
											)),
										$js->return($js->result),
									)),
			);
			return $settings;
		}
	}
